package com.bjpowernode.javase.string;

public class StringTest {
    public static void main(String[] args) {
        char c = "中国人".charAt(1);   //"中国人"是字符串对象，只要是对象就能.
        System.out.println(c);   //国


        int result = "abc".compareTo("abc");
        System.out.println(result);  //0

        int result2 = "abcd".compareTo("abce");
        System.out.println(result2);  //-1

        int result3 = "abce".compareTo("abcd");
        System.out.println(result3);   //1


        System.out.println("HelloWorld".contains("Hello"));  //true
        System.out.println("HelloWorld".contains("HE"));     //false

        System.out.println("test.txt".endsWith("txt"));      //true


        System.out.println("abc".equals("abc"));     //true
        System.out.println("abcd".equals("abce"));   //false
        System.out.println("abce".equals("abcd"));   //false


        System.out.println("Abc".equalsIgnoreCase("abc"));   //true

        byte[] bytes = "abcdef".getBytes();
        for(int i = 0; i < bytes.length; i++)
        {
            System.out.println(bytes[i]);
        }


        System.out.println("cndhnjavakdkendhcdjava".indexOf("java"));   //5


        String s = "";
        System.out.println(s.isEmpty());  //true

        System.out.println("cndhnjavakdkendhcdjava".lastIndexOf("java"));   //18

        String newString  = "http://www.baidu.com".replace("http://", "https://");
        System.out.println(newString);

        String[] ymd = "198010901".split("0");
        for(int i = 0; i < ymd.length; i++)
        {
            System.out.println(ymd[i]);
        }
    }
}
